from PySide6.QtWidgets import QMenu
from PySide6.QtGui import QKeySequence

# 添加 文件、编辑、格式、查看、帮助 菜单

class FileMenu(QMenu):
    """文件菜单

    :param QMenu: PySide6 菜单类
    """
    def __init__(self):
        """初始化
        """
        super().__init__()
        self.setup_ui()
    
    def setup_ui(self):
        """设置菜单项
        """
        self.setTitle("文件(&F)")
        new_file = self.addAction("新建(&N)")
        new_window = self.addAction("新窗口(&W)")
        open_file = self.addAction("打开(&O)")
        save_file = self.addAction("保存(&S)")
        self.addSeparator()
        save_file_as = self.addAction("另存为(&A)")
        print_file = self.addAction("打印(&P")
        self.addSeparator()
        exit_ = self.addAction("退出(&X)")

        # 添加快捷方式
        new_file.setShortcut(QKeySequence.StandardKey.New)
        new_window.setShortcut("Ctrl+Shift+N")
        open_file.setShortcut(QKeySequence.StandardKey.Open)
        save_file.setShortcut(QKeySequence.StandardKey.Save)
        save_file_as.setShortcut(QKeySequence.StandardKey.SaveAs)
        print_file.setShortcut(QKeySequence.StandardKey.Print)
        exit_.setShortcut(QKeySequence.StandardKey.Close)

class EditMenu(QMenu):
    """编辑菜单

    :param QMenu: PySide6 菜单类
    """
    def __init__(self):
        """初始化
        """
        super().__init__()
        self.setup_ui()
    
    def setup_ui(self):
        """设置菜单项
        """
        self.setTitle("编辑(&E)")
        undo = self.addAction("撤销(&U)")
        self.addSeparator()
        cut =  self.addAction("剪切(&T)")
        copy = self.addAction("复制(&C)")
        paste = self.addAction("粘贴(&P)")
        delete = self.addAction("删除(&L)")
        self.addSeparator()
        search =  self.addAction("使用Bing搜索")
        find_ = self.addAction("查找(&F)")
        find_next = self.addAction("查找下一个(&N)")
        find_previous =  self.addAction("查找上一个(&V)")
        replace =  self.addAction("替换(&R)")
        goto =self.addAction("转到(&G)")
        self.addSeparator()
        select_all = self.addAction("全选(&A)")
        date_ = self.addAction("时间/日期(&D)")

        # 添加快捷方式
        undo.setShortcut(QKeySequence.StandardKey.Undo)
        cut.setShortcut(QKeySequence.StandardKey.Cut)
        copy.setShortcut(QKeySequence.StandardKey.Copy)
        paste.setShortcut(QKeySequence.StandardKey.Paste)
        delete.setShortcut(QKeySequence.StandardKey.Delete)
        find_.setShortcut(QKeySequence.StandardKey.Find)
        find_next.setShortcut(QKeySequence.StandardKey.FindNext)
        find_previous.setShortcut(QKeySequence.StandardKey.FindPrevious)
        replace.setShortcut(QKeySequence.StandardKey.Replace)
        goto.setShortcut("Ctrl+G")
        select_all.setShortcut(QKeySequence.StandardKey.SelectAll)
        date_.setShortcut("F5")

class FormatMenu(QMenu):
    """格式菜单

    :param QMenu: PySide6 菜单类
    """
    def __init__(self):
        """初始化
        """
        super().__init__()
        self.setup_ui()

    def setup_ui(self):
        """设置菜单项
        """
        self.setTitle("格式(&O)")
        self.addAction("自动换行(&W)")
        self.addAction("字体(&F)")

class ViewMenu(QMenu):
    """查卡菜单

    :param QMenu: PySide6 菜单类
    """
    def __init__(self):
        """初始化
        """
        super().__init__()
        self.setup_ui()

    def setup_ui(self):
        """设置菜单项
        """
        self.setTitle("查看(&V)")
        zoom_menu = self.addMenu("缩放(&Z)")
        zoom_in = zoom_menu.addAction("放大(&I)")
        zoom_out = zoom_menu.addAction("缩小(&O)")
        zoom_back = self.addAction("恢复默认缩放")
        show_status_bar_ =  self.addAction("状态栏(&S)")

        zoom_in.setShortcut(QKeySequence.StandardKey.ZoomIn)
        zoom_out.setShortcut(QKeySequence.StandardKey.ZoomOut)
        zoom_back.setShortcut("Ctrl+0")

class HelpMenu(QMenu):
    """帮助菜单

    :param QMenu: PySide6 菜单类
    """
    def __init__(self):
        """初始化
        """
        super().__init__()
        self.setup_ui()

    def setup_ui(self):
        """设置菜单项
        """
        self.setTitle("帮助(&H)")
        help_web_info = self.addAction("查看帮助(&H)")
        self.addAction("发送反馈(&F)")
        self.addSeparator()
        about_notepad = self.addAction("关于记事本(&A)")
